<template>
	<div style="width: 100%; height: 100%">
		<div class="drawer_box" v-if="isShows" style="margin-top: 10px;">
			<el-form ref="ruleFormRef" :model="formDataJJB" label-position="right" label-width="140px"
				class="dd-edit-box">
				<div class="date_box">
					<div>
						值班日期：
						{{ pshiftStartDate }} &nbsp; 至 &nbsp;
						{{ pshiftEndDate }}
					</div>
				</div>

				<div class="jjb border_table isTable" style="border-bottom: none; margin-bottom: -1px">
					<el-table @cell-click="zbLdCellClick" border :data="tabelLdzb" style="width: 100%">
						<el-table-column prop="title" label="" width="80" align="center" />
						<el-table-column prop="name1" label="时间" width="100">
						</el-table-column>
						<el-table-column prop="name2" label="" align="center" />
						<el-table-column prop="name3" label="" width="100" align="center" />
						<el-table-column prop="name4" label="" align="center" />
					</el-table>
				</div>

				<div class="jjb border_table isTable" style="border-bottom: none">
					<el-table @cell-click="zbCellClick" border :span-method="objectSpanMethod2" :data="tableDataZb"
						style="width: 100%">
						<el-table-column prop="title" label="" width="80" align="center" />
						<el-table-column prop="date" label="时间" width="200">
							<template #default="scope">
								<div style="text-align: left">
									{{ scope.row.date }} &nbsp;
									{{ scope.row.pshiftStart + " - " + scope.row.pshiftEnd }}
								</div>
							</template>
						</el-table-column>
						<el-table-column prop="names" label="" width="100" align="center" />
						<el-table-column prop="b" label="" align="center" />
					</el-table>
				</div>
				<div class="jj_box" style="display: flex; width: 100%; justify-content: space-between"></div>

				<div class="jjb border_table isTable"
					style="border-bottom: none; border-top: none; margin-bottom: -1px">
					<!-- 罪犯情况 -->
					<el-table border :span-method="objectSpanMethodCv" :data="ycqkList" style="width: 100%"
						@cell-click="ycsbCellClick">
						<el-table-column prop="title" label="" width="80" align="center" />
						<el-table-column prop="type" label="类型" width="136" align="center">
							<template #default="scope">
								{{ scope.row.exceptType + "" }}
							</template>
						</el-table-column>
						<el-table-column prop="content" label="情况描述">
							<template #default="scope">
								<div style="display: flex" v-for="(item, index) in getContet(scope.row.ids, '罪犯')"
									:key="index">
									<div style="margin-right: 10px" class="yc_date">
										{{
                      item.createDate.replace(/T/g, " ").split(" ")[0] +
                      " " +
                      item.createDate
                        .replace(/T/g, " ")
                        .split(" ")[1]
                        .split(":")[0] +
                      ":" +
                      item.createDate
                        .replace(/T/g, " ")
                        .split(" ")[1]
                        .split(":")[1]
                    }}
									</div>
									<div style="
                      margin-right: 10px;
                      min-width: 120px;
                      text-align: left;
                    " class="yc_content">
										情况： {{ item.content }}
									</div>

									<div v-if="item.handleContent" style="margin-right: 10px" class="yc_handleContent">
										处理： {{ item.handleContent }}
									</div>
								</div>
							</template>
						</el-table-column>
					</el-table>
				</div>

				<!-- 监区情况 -->
				<div class="jjb border_table isTable"
					style="border-bottom: none; border-top: none; margin-bottom: -1px">
					<el-table border :span-method="objectSpanMethod1" :data="jqqkArr" style="width: 100%">
						<el-table-column prop="title" label="" width="80">
						</el-table-column>

						<el-table-column prop="" label="情况描述">
							<template #default="scope">
								<div class="colmm_table">
									<div class="table_top">
										<div>监区</div>
										<div>监区领导</div>
										<div>在册</div>
										<div>在押</div>
										<div>实押</div>
										<div>监内住院</div>
										<div>离监探亲</div>
										<div>禁闭</div>
										<div>惩戒训导</div>
										<div>监外住院</div>
										<div>监外执行</div>

									</div>
									<el-table border :data="colmmTable" style="width: 100%">
										<el-table-column prop="name" label="监区" width="118" align="center">
											<template #default="scope">
												<div>
													{{ scope.row.name }}
												</div>
											</template>
										</el-table-column>
										<el-table-column prop="name" label="监区领导" align="center">
											<template #default="scope">
												<div>
													{{ scope.row.jqld }}
												</div>
											</template>
										</el-table-column>

										<el-table-column prop="name" label="在册" align="center">
											<template #default="scope">
												{{ scope.row.zcfr }}
											</template>
										</el-table-column>
										<el-table-column prop="zy" label="在押" align="center">
											<template #default="scope">
												{{ scope.row.zyfr }}
											</template>
										</el-table-column>
										<el-table-column prop="syfr" label="实押" align="center">
										</el-table-column>

										<el-table-column align="center" prop="jnzy" label="监内住院" />
										<el-table-column align="center" prop="ljtq" label="离监探亲" />
										<el-table-column align="center" prop="jbfr" label="禁闭" />
										<el-table-column align="center" prop="cjxd" label="惩戒训导" />
										<el-table-column align="center" prop="jwzy" label="监外住院" />
										<el-table-column align="center" prop="jwzx" label="监外执行" />
										<!-- <el-table-column
                      align="center"
                      prop="lnzt"
                      label="历年在逃"
                    >
                      {{ "--" }}
                    </el-table-column> -->
									</el-table>
								</div>
							</template>
						</el-table-column>
					</el-table>
				</div>
		
			</el-form>

		</div>
		<div v-else>
			<zhzxJjbSave :listData="listData" :listDatald="listDatald" :jcNub="jcNub" :jcNubCv="jcNubCv"
				:orgIds="orgIds" :types="types" :data="dataSon" @childEventSon="childEventSon" :account="account"
				:ggjjObj="ggjjObj" :zfrs="zfrs" :xhNub="xhNub" :jbArr="jbArr" :jbArr2="jbArr2" />
		</div>
	</div>
</template>

<script setup>
	import {
		ElMessage
	} from "element-plus";
	import http from "@/utils/api";
	// import zhzxJjbSave from "./zhzxJjbSave.vue";
	import zhzxJjbSave from "./zhzxJjbSave.vue";
	import {
		Search,
		Share,
		Upload,
		TakeawayBox,
		Refresh,
		Collection,
		Plus,
		Loading,
		FolderDelete,
		Back,
	} from "@element-plus/icons-vue";
	import {
		ref,
		watch,
		onMounted,
		onBeforeUnmount,
		reactive,
		onBeforeMount,
		nextTick,
		onUnmounted,
	} from "vue";
	import {
		defineProps,
		defineEmits,
		computed
	} from "vue";
	const props = defineProps({
		sonData: {
			type: String,
			default: "",
		},
		orgIds: {
			type: Number,
			default: 22,
		},
		orgName: {
			type: String,
			default: "",
		},
		userName: {
			type: String,
			default: "",
		},
		account: {
			type: String,
			default: "",
		},

		dialogVisible10: {
			type: Boolean,
			default: true,
		},
		pidObj: {
			type: Object,
			default: {},
		},
		ldbcObj: {
			type: Object,
			default: {},
		},
		pids: {
			type: Number,
			default: 0,
		},
		jgqkList: {
			type: Array,
			default: [],
		},
		sonTableData: {
			type: Array,
			default: [],
		},
		jqqkList: {
			type: Array,
			default: [],
		},
	});

	const colmmTable = ref([]);

	const objectSpanMethod2 = ({
		row,
		column,
		rowIndex,
		columnIndex
	}) => {
		if (columnIndex === 0) {
			if (rowIndex == 0) {
				return {
					rowspan: 4,
					colspan: 1,
				};
			} else {
				return {
					rowspan: 0,
					colspan: 0,
				};
			}
		}
	};

	const objectSpanMethod1 = ({
		row,
		column,
		rowIndex,
		columnIndex
	}) => {
		if (columnIndex === 0) {
			if (rowIndex == 0) {
				return {
					rowspan: 6,
					colspan: 1,
				};
			} else {
				return {
					rowspan: 0,
					colspan: 0,
				};
			}
		}

		return;
		//  console.log(rowIndex,columnIndex);
		//  console.log(countedIds.value,'countedIds');

		//  if (columnIndex === 0) { // 只对第一列进行合并
		//     let count = 1;
		//     for (let i = rowIndex + 1; i < gzqkList.value.length; i++) {
		//       if (gzqkList.value[i].type === row.type) {
		//         count++;
		//       } else {
		//         break;
		//       }
		//     }
		//     if (count > 1) {
		//         console.log(count,'count');

		//       return [count, 1]; // 返回合并的行数和列数
		//     }
		//     if( rowIndex == count){
		//         return [0, 0]
		//     }
		//   }
		//   return [1, 1]; // 默认不合并

		//  return
		if (columnIndex === 0) {
			let nubArr = countedIds.value;
			let nubs = 0;
			for (let i = 0; i < nubArr.length; i++)
				if (rowIndex == nubArr[i].a) {
					return {
						rowspan: nubArr[i].b,
						colspan: 1,
					};
				} else if (i == 0) {
				if (rowIndex > nubArr[i].a && rowIndex < nubArr[i].b) {
					nubs += nubArr[i].b;
					return {
						rowspan: 0,
						colspan: 0,
					};
				}
			} else {
				if (rowIndex > nubs && rowIndex < nubArr[i].b + nubArr[i].a) {
					nubs += nubArr[i].b;
					return {
						rowspan: 0,
						colspan: 0,
					};
				}
			}
		}
	};

	/**
	   *
	   * @param param0 return {rowspan: 1,colspan: 1 } 表示表格不变
	  return {rowspan: 2,colspan: 1 } 表示表格向下合并一个单元格
	  return {rowspan: 1,colspan: 2 } 表示表格向右合并一个单元格
	  return {rowspan: 0,colspan: 0 } 表示删除此单元格
	   */

	const objectSpanMethodCv = ({
		row,
		column,
		rowIndex,
		columnIndex
	}) => {
		if (columnIndex === 0) {
			if (rowIndex == 0) {
				return {
					rowspan: 6,
					colspan: 1,
				};
			} else {
				return {
					rowspan: 0,
					colspan: 0,
				};
			}
		}
	};
	const emit = defineEmits(["childEvent"]);
	const types = ref("");
	let dataSon = ref({});

	let tabelLdzb = ref([{
		name1: "总值班长",
		title: "领导",
		name2: "",
		name3: "值班主任",
		name4: "",
	}, ]);

	const tableDataZb = ref([{
			date: "白班",
			name: "领导",
			a: "",
			names: "民警",

			d: "",
			b: "",
			c: "值班日期",
			pshiftStart: "",
			pshiftEnd: "",
			title: "民警",
		},
		{
			date: "夜班",
			name: "领导",
			a: "",
			names: "民警",
			d: "",
			b: "",
			c: "值班日期",
			pshiftStart: "",
			pshiftEnd: "",
			title: "民警",
		},
	]);
	let formDataJJB = ref({});
	const getContet = (row, is) => {
		if (row && is == "罪犯") {
			let arrs = row.split(",").filter((item) => item != "undefined");

			const result = byYcData.value.filter((item) =>
				arrs.includes(String(item.id))
			);

			return result;
		}
		if (row && is == "工作") {
			let arrs = row.split(",").filter((item) => item != "undefined");

			const result = gzqkData.value.filter((item) =>
				arrs.includes(String(item.id))
			);

			return result;
		}
		if (row && is == "机构") {
			let arrs = row.split(",").filter((item) => item != "undefined");

			const result = props.jgqkList.filter((item) =>
				arrs.includes(String(item.id))
			);

			return result;
		}
		if (row && is == "监区") {
			let arrs = row.split(",").filter((item) => item != "undefined");

			const result = props.jqqkList.filter((item) =>
				arrs.includes(String(item.id))
			);

			return result;
		}

		//  return text.split(',').filter((itz)=>itz)
	};

	let zfrs = ref(0);
	onBeforeMount(() => {});
	let dateSfm = ref("");
	let hour = ref("");
	let daydata = ref("");
	// 获取年月日 时
	const getFormattedDateTime = () => {
		const now = new Date();
		const year = now.getFullYear();
		const month = String(now.getMonth() + 1).padStart(2, "0");
		const day = String(now.getDate()).padStart(2, "0");
		const hours = String(now.getHours()).padStart(2, "0");
		const minutes = String(now.getMinutes()).padStart(2, "0");
		const seconds = String(now.getSeconds()).padStart(2, "0");
		dateSfm.value = `${hours}:${minutes}:${seconds}`;
		hour.value = String(now.getHours()).padStart(2, "0");
		daydata.value = `${year}-${month}-${day}`;

		return `${year}-${month}-${day} ${hour.value}`;
	};
	let ycqkList = ref([{
			title: "值班警务内容",
			exceptType: "设备运行情况",
			content: "",
		},
		{
			title: "值班警务内容",
			exceptType: "视频巡查情况",
			content: "",
		},
		{
			title: "值班警务内容",
			exceptType: "报警处置情况",
			content: "",
		},
		{
			title: "值班警务内容",
			exceptType: "有无检查",
			content: "",
		},
		{
			title: "值班警务内容",
			exceptType: "上级通知",
			content: "",
		},
		{
			title: "值班警务内容",
			exceptType: "重点监控罪犯情况",
			content: "",
		},
	]);
	let ycqkids = ref([]);
	let gzjjList = ref([{
			title: "强化信息研判分析",
			type: "指挥中心例行研判",
			content: "",
		},
		// {
		//   title: "强化信息研判分析",
		//   type: "",
		//   content: "",
		// },

		// {
		//   title: "强化信息研判分析",
		//   type: "",
		//   content: "",
		// },
	]);
	let byYcData = ref([]);
	let gzqkData = ref([]);
	let DutySList = ref([]);
	let tbObj = ref({});
	let pshiftEndDate = ref("");
	let pshiftStartDate = ref("");
	let bbzf = ref(0);
	let ybzf = ref(0);
	let gzqkIds = ref([]);

	//异常情况数据
	const getExceptionReportSelect = async () => {
		let obj = {
			page: 1,
			limit: 99,
			orgId: props.orgIds,
			exceptType: "",
			startDate: pshiftStartDate.value,
			endDate: pshiftEndDate.value,
			// startDate: getTimeRange().split("至")[0].split(" ")[0],
			// endDate: getTimeRange().split("至")[1].split(" ")[1],
			state: "0,1",
			reportState: "0,1,2,3,4",
			reportType: "zhzx",
		};
		let res = await http.znjw.ExceptionReportSelect(obj);
		if (!res) return;
		let ycArr = res.data.data;

		if (Array.isArray(ycArr)) {
			ycqkids.value = ycArr.map((item) => item.id);
			byYcData.value = ycArr;
			ycArr.forEach((item) => {
				if (item.content) {
					ycqkList.value.forEach((itz) => {
						if (itz.exceptType == item.exceptType) {
							itz["ids"] += "," + item.id;
						}
					});
				}

				if (item.exceptType == "指挥中心例行研判") {
					let str = "";
					str =
						item.reportState == 1 ?
						"上报" :
						item.reportState == 2 ?
						"通报" :
						item.reportState == 3 ?
						"预警" :
						"汇总";
					gzjjList.value[0].content =
						item.content + " " + " " + "研判结果：" + str;
					// + ' '+'研判结果' + item.reportState == 1?'上报':item.reportState == 2?'通报':item.reportState == 3?'预警':'汇总'
				}
			});
		}
	};

	let listData = ref([]);
	let jcNub = ref(0);
	let jcNubCv = ref(0);
	let listDatald = ref([]);
	//获取警察值班人员
	const getZdbSelect = async () => {
		//领导
		console.log(props.ldbcObj, "props.ldbcObj");

		if (props.ldbcObj?.children && props.ldbcObj.children.length) {
			let resc = await http.znjw.ZdbSelect({
				type: "zhzxld",
				zbType: "1",
				orgId: props.orgIds || "",
				shift: props.ldbcObj.id,
				account: "",
				date: daydata.value,
			});
			if (!resc) return;
			if (resc.data.length) {
				if (resc.code == 0) {
					let zbArrCv = resc.data;
					zbArrCv.length &&
						zbArrCv.forEach((item) => {
							item["zbryInfoArr"] =
								item?.zbry &&
								item.zbry.split(",").map((itz, index) => {
									return {
										name: item.zbry.split(",")[index],
										id: "",
										is: false,
										zbryAccount: item.zbryAccount.split(",")[index],
									};
								});
						});
					listDatald.value = zbArrCv;
					listDatald.value.forEach((item) => {
						if (props.ldbcObj.children.length) {
							tabelLdzb.value.forEach((itz) => {
								jcNubCv.value += 1;
								if (itz.name1 == item.shiftName) {
									itz.name2 = item.zbry;
								}
								if (itz.name3 == item.shiftName) {
									itz.name4 = item.zbry;
								}
							});
						}
					});
				}
			}
		}

		// 民警

		if (props.pidObj.children.length) {
			tableDataZb.value = props.pidObj.children.map((item) => {
				return {
					title: "民警",
					date: item.name,
					name: "",
					a: "",
					names: "值班民警",
					d: "",
					b: "",
					c: "值班日期",
					pshiftStart: item.start.slice(0, 5),
					pshiftEnd: item.end.slice(0, 5) + " " + (item.next == 1 ? "(次日)" : ""),
				};
			});
		}

		let res = await http.znjw.ZdbSelect({
			type: "zhzx",
			zbType: "1",
			orgId: props.orgIds || "",
			shift: props.pids,
			account: "",
			date: daydata.value,
		});
		if (!res) return;
		if (res.code == 0) {
			let zbArr = res.data;
			zbArr.length &&
				zbArr.forEach((item) => {
					item["zbryInfoArr"] =
						item?.zbry &&
						item.zbry.split(",").map((itz, index) => {
							return {
								name: item.zbry.split(",")[index],
								id: "",
								is: false,
								zbryAccount: item.zbryAccount.split(",")[index],
							};
						});
				});
			listData.value = zbArr;

			listData.value.forEach((item) => {
				if (props.pidObj.children.length) {
					tableDataZb.value.forEach((itz) => {
						jcNub.value += 1;
						if (itz.date == item.pshiftName) {
							if (itz.name == item.shiftName) {
								itz.a = item.zbry;
							}
							if (itz.names == item.shiftName) {
								itz.b = item.zbry;
							}
						}
					});
				}
			});
		}
	};

	let isShows = ref(true);
	const ycsbCellClick = (row, clomm) => {
		if (clomm.label == "类型") {
			dataSon.value = row;
			types.value = "罪犯";
			isShows.value = false;
		}
	};
	let xhNub = ref(0);
	//值班选人
	const zbCellClick = (row, clomm) => {
		if (clomm.label != "时间") return;
		tableDataZb.value.forEach((item, index) => {
			if (item.date == row.date) {
				xhNub.value = index + 1;
			}
		});
		if (tableDataZb.value.length == xhNub.value) {
			xhNub.value = 0;
		}
		dataSon.value = row;
		types.value = "值班";
		let arrs = tableDataZb.value.filter((item) => item.date != row.date);
		zfrs.value = arrs[0].d;
		isShows.value = false;
	};
	const zbLdCellClick = (row, clomm) => {
		dataSon.value = row;
		types.value = "领导值班";
		isShows.value = false;
	};

	const getTimeRange = () => {
		const now = new Date();
		const targetTime = new Date(
			now.getFullYear(),
			now.getMonth(),
			now.getDate(),
			9,
			10
		);

		if (now > targetTime) {
			// 当前时间大于早上9:10，返回 "今日早上9:10到明天早上9:10"
			return `${formatDate(now)} 09:10 至 ${formatDate(
      new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1)
    )} 09:10`;
		} else {
			// 当前时间小于早上9:10，返回 "昨天早上9:10到今天早上9:10"
			return `${formatDate(
      new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1)
    )} 09:10 至 ${formatDate(now)} 09:10`;
		}
	};
	const formatDate = (date) => {
		const year = date.getFullYear();
		const month = String(date.getMonth() + 1).padStart(2, "0"); // 月份从0开始，需要加1
		const day = String(date.getDate()).padStart(2, "0");
		return `${year}-${month}-${day}`;
	};
	let reportUser = ref({});
	let ggjjObj = ref({});
	let jbArr = ref([]);
	let jbArr2 = ref([]);
	const getShiftDutySelect = async () => {
		let obj = {
			page: 1,
			limit: 200,
			orgId: props.orgIds,
			startDate: pshiftStartDate.value,
			endDate: pshiftEndDate.value,
			dutyType: "zhzx",
			// startDate: getTimeRange().split("至")[0].split(" ")[0] + " " + "09:10:00",
			// endDate: getTimeRange().split("至")[1] + ":00",
		};
		let res = await http.znjw.ShiftDutySelect(obj);
		if (res && res.code == 0) {
			DutySList.value = res.data.data;
			sessionStorage.setItem("formDataJJB", JSON.stringify({}));

			if (DutySList.value[0]?.handleContent) {
				jbArr.value = JSON.parse(DutySList.value[0].handleContent);
			}
			if (DutySList.value[0]?.takeContent) {
				jbArr2.value = JSON.parse(DutySList.value[0].takeContent);
			}

			DutySList.value.forEach((item) => {
				tbObj.value.reportUser = item.reportUser;

				sessionStorage.setItem("formDataJJB", JSON.stringify(item));
				ggjjObj.value = item;
				reportUser.value = item.reportUser;
				//罪犯人数
				tableDataZb.value[0].d = item.ybzf;
				tableDataZb.value[1].d = item.bbzf;
			});
		}
	};

	const jjbSave = async () => {
		let arrIds = [...ycqkids.value];
		let gzqkId = [...gzqkIds.value];

		let res;
		if (!DutySList.value.length) {
			let obj = {
				orgId: props.orgIds,
				startDate: pshiftStartDate.value,
				endDate: pshiftEndDate.value,
				bbzf: bbzf.value,
				ybzf: ybzf.value,
				reportIds: arrIds.join(",") || "",
				workIds: gzqkId.join(",") || "",
				clsx: formDataJJB.value?.clsx || "",
				gzyq: formDataJJB.value?.gzyq || "",
				file: "",
				dutyType: "zhzx",
				remark: formDataJJB.value?.remark || "",
				jnrs: formDataJJB.value?.jnrs || 0,
				jwrs: formDataJJB.value?.jwrs || 0,
				cjrs: formDataJJB.value?.cjrs || 0,
				zyrs: formDataJJB.value?.zyrs || 0,
				qyrs: formDataJJB.value?.qyrs || 0,
				reportUser: tbObj.value?.reportUser || "",
				handleContent: formDataJJB.value?.handleContent || "",
				takeContent: formDataJJB.value?.takeContent || "",
			};
			console.log(obj, "交接班数据");

			res = await http.znjw.ShiftDutyAdd(obj);
		} else {
			let obj = {
				bbzf: bbzf.value || formDataJJB.value.bbzf,
				ybzf: ybzf.value || formDataJJB.value.ybzf,
				id: DutySList.value[0].id,
				clsx: formDataJJB.value.clsx || "",
				gzyq: formDataJJB.value.gzyq || "",
				remark: formDataJJB.value.remark,
				reportIds: arrIds.join(",") || "",
				workIds: gzqkId.join(",") || "",
				jnrs: formDataJJB.value.jnrs || 0,
				jwrs: formDataJJB.value.jwrs || 0,
				cjrs: formDataJJB.value.cjrs || 0,
				zyrs: formDataJJB.value.zyrs || 0,
				qyrs: formDataJJB.value.qyrs || 0,
				reportUser: tbObj.value?.reportUser || "",
				handleContent: formDataJJB.value?.handleContent || "",
				takeContent: formDataJJB.value?.takeContent || "",
			};
			res = await http.znjw.ShiftDutyUpdate(obj);
		}
		if (res && res.code == 0) {
			ElMessage({
				message: "保存完成",
				type: "success",
				plain: true,
			});
			emit("childEvent", "false");
		}
	};
	const childEventSon = (data) => {
		isShows.value = true;
		if (typeof data == "string") {
			if (data == "值班") {
				getZdbSelect();
				// getShiftDutySelect()
			}
			if (data == "罪犯") {
				getExceptionReportSelect();
				// getShiftDutySelect();
			}
		}
		if (data.value?.reportUser) {
			tbObj.value = data.value;
			jjbSave();
			return;
		}
		// 值班
		if (data?.isBs) {
			formDataJJB.value = data.data;
			if (data?.handleContent) {
				formDataJJB.value.handleContent = JSON.stringify(data.handleContent);
			}
			if (data?.takeContent) {
				formDataJJB.value.takeContent = JSON.stringify(data.takeContent);
			}
			console.log("走了", formDataJJB.value);

			jjbSave();
		}
		if (typeof data == "object" && !data?.value?.reportUser && !data?.isBs) {
			formDataJJB.value = data;

			jjbSave();
			return;
		}
	};

	const getColor = (row) => {
		// if(row.a || row.b){
		//   return '#2ab051'
		// }else{
		//   return 'red'
		// }
	};

	const tbrClick = () => {
		dataSon.value = reportUser.value;
		types.value = "填报人";
		isShows.value = false;
	};

	const getTimeRangeFun = (input) => {
		const today = new Date();
		const tomorrow = new Date(today);
		tomorrow.setDate(today.getDate() + 1);

		const formatDates = (date) => {
			const year = date.getFullYear();
			const month = String(date.getMonth() + 1).padStart(2, "0");
			const day = String(date.getDate()).padStart(2, "0");
			return `${year}-${month}-${day}`;
		};

		if (input == 0) {
			return `${formatDates(today)} 至 ${formatDates(tomorrow)}`;
		} else if (input == 1) {
			return `${formatDates(today)} 至 ${formatDates(today)}`;
		}
	};
	// 机构数组
	let jgqkArr = ref([{
		title: "机构情况",
		exceptType: "社情信息",
		content: "",
	}, ]);
	//监区数组
	let jqqkArr = ref([{
		title: "狱情信息",
		exceptType: "",
		content: "",
	}, ]);

	watch(
		() => props.dialogVisible10,
		(newValue, oldValue) => {
			if (newValue) {
				if (props.sonTableData) {
					colmmTable.value = props.sonTableData;
					// console.log(props.sonTableData, "][][][][][]");
				}

				if (props.pidObj?.id) {
					pshiftStartDate.value = props.pidObj.curStartDate;
					pshiftEndDate.value = props.pidObj.curEndDate;
				}

				if (props.jgqkList.length) {
					props.jgqkList.forEach((item) => {
						if (item.content) {
							jgqkArr.value.forEach((itz) => {
								itz["ids"] += "," + item.id;
							});
						}
					});
				}
				if (props.jqqkList.length) {
					props.jqqkList.forEach((item) => {
						if (item.content) {
							jqqkArr.value.forEach((itz) => {
								itz["ids"] += "," + item.id;
							});
						}
					});
				}

				//d当前时间
				getFormattedDateTime();
				isShows.value = true;
				getZdbSelect();
				//罪犯情况
				getExceptionReportSelect();

				//交接班列表数据
				getShiftDutySelect();
			}
		}, {
			deep: true, // 深度监听
			immediate: true, // 立即触发回调
		}
	);
</script>

<style scoped lang="scss">
	::v-deep .colmm_table {
		.el-table__header-wrapper {
			display: none !important;
		}

		.el-scrollbar__view {
			width: 100%;
		}
	}

	.colmm_table {
		width: 100%;
		z-index: 999;
		height: 300px;
		overflow-y: scroll;
		padding-top: 10px;

		.table_top {
			height: 60px;
			width: 100%;
			// border: 1px solid red;
			display: flex;
			align-items: center;
			border: 1px solid rgb(5, 112, 146);
			border-bottom: none;

			div {
				flex: 1;
				border-right: 1px solid rgb(5, 112, 146);
				width: 60px;
				transform: translateX(1px);
			}
		}

		// border: 1px solid red;
	}

	::v-deep .isTable {
		.el-table {
			background-color: rgb(8, 32, 78) !important;

			.el-table tr {
				background-color: rgb(8, 32, 78) !important;
			}

			.el-table thead tr {
				display: none !important;
			}

			.cell {
				height: auto;
				color: #fff;
				text-align: center;
				// border: 1px solid #ccc;
				background: rgb(8, 32, 78) !important;
				font-size: 12px;
				line-height: 34px;
			}

			--el-table-border-color: rgb(5, 112, 146);
		}
	}

	.border_table {
		border-right: none;
	}

	.jjb_text {
		position: absolute;
		left: 50%;
		transform: translate(-50%, -50%);
		top: 40px;
		font-size: 16px;
		font-weight: bold;
	}

	.date_box {
		width: 100%;
		display: flex;
		justify-content: space-between;
		padding: 0 14px;
		padding-right: 64px;
		color: white;
		margin-bottom: 6px;
	}

	.wrap_text {
		width: 60px;
		overflow-wrap: break-word;
		/* 新版浏览器支持 */
	}

	.yc_table {
		width: 100%;
		overflow-y: scroll;
		color: white;
		// height: 66px;
		height: 200px;

		.table_item {
			width: 100%;
			height: 30px;
			cursor: pointer;
			height: 25px;
			justify-content: space-evenly;
			font-size: 12px;
		}
	}

	.jj_box {
		margin-bottom: -1px;
		font-size: 14px;
	}

	.drawer_box {
		width: 100%;
		height: 100%;
		overflow-y: scroll;
		box-sizing: border-box;
		padding: 0 20px;
		position: relative;

		.dialog-footer {
			position: absolute;
			bottom: -50px;
			right: 2px;
			// font-size: 18px;
		}
	}
</style>